package com.biz.primus.ms.oms.api;

import com.biz.primus.base.vo.PageResult;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.oms.vo.*;
import com.biz.primus.model.oms.vo.returns.*;
import com.biz.primus.ms.oms.service.core.OrderInterceptService;
import com.biz.primus.ms.oms.service.core.OrderQueryService;
import com.biz.primus.ms.oms.service.returns.OrderReturnQueryService;
import com.biz.primus.ms.oms.service.returns.OrderReturnStateService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LGJ
 * @date  2017/11/25
 */
@RestController
@RequestMapping("soa/managementReturn")
public class OmsManagementReturnController {


    @Autowired
    private OrderReturnQueryService orderReturnQueryService;

    @Autowired
    private OrderReturnStateService orderReturnStateService;

    @PostMapping("managementReturnQuery")
    @ApiOperation("后台退单列表查询")
    public PageResult<OmsReturnVo> managementReturnQuery(@RequestBody OrderReturnQueryVo orderReturnQueryVo){
        return orderReturnQueryService.managementReturnQueryList(orderReturnQueryVo);
    }

    @GetMapping("auditReturnDetail")
    @ApiOperation("审核退单详情")
    public OmsReturnVo auditReturnDetail(@ApiParam(value = "退单编码", required = true) @RequestParam("returnCode")String returnCode){
        return orderReturnQueryService.auditReturnDetail(returnCode);
    }

    @PostMapping("auditReturn")
    @ApiOperation("审核退单")
    public void auditReturn(@RequestBody AuditRequestVo auditRequestVo){
        orderReturnStateService.auditReturns(auditRequestVo);
    }

    @PostMapping("modifyReturns")
    @ApiOperation("修改退单信息")
    public void modifyReturns(@RequestBody ModifyReturnRequestVo modifyReturnRequestVo){
        orderReturnStateService.modifyReturns(modifyReturnRequestVo);
    }

    @PostMapping("managementRefundQuery")
    @ApiOperation("后台退款列表查询")
    public PageResult<OmsRefundVo> managementRefundQuery(@RequestBody OrderRefundQueryVo orderReturnQueryVo){
        return orderReturnQueryService.managementRefundQueryList(orderReturnQueryVo);
    }

    @GetMapping("getOmsRefundDetail")
    @ApiOperation("获取退款信息")
    public OmsRefundDetailVo getOmsRefundDetail(String refundCode){
        return orderReturnQueryService.getRefundDetail(refundCode);
    }

    @PostMapping("modifyRefund")
    @ApiOperation("修改退款信息")
    public void modifyRefund(@RequestBody RefundRequestVo refundRequestVo){
        orderReturnStateService.modifyRefunds(refundRequestVo);
    }

    @PostMapping("closeReturn")
    @ApiOperation("客服取消退单")
    public void closeReturn(@RequestBody  OmsReturnOperationRequest omsReturnOperationRequest){
        orderReturnStateService.closeReturns(omsReturnOperationRequest);
    }

    /*@GetMapping("getApplyforReturn")
    @ApiOperation("申请退货的订单详情")
    public OmsOrderRespVo getApplyforReturn(@ApiParam(value = "订单编码" ,required = true) @RequestParam("orderCode") String orderCode){
        return orderQueryService.getApplyforReturn(orderCode);
    }*/

 /*   @PostMapping("applyforReturns")
    @ApiOperation("申请退货")
    public void applyforReturns(@RequestBody  ApplyforReturnVo applyforReturnVo){
        orderReturnStateService.applyforReturns(applyforReturnVo);
    }*/
}
